package com.books.mapper.connection;

import com.books.model.entity.backcontroller.Connection;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface ConnectionMapper {
    @Select ("select * from connection where people_id=#{peopleId}")
    List<Connection> connection (Integer peopleId);

    @Select("select * from connection where people_id=#{peopleId} and book_id=#{bookId} and book_type=#{bookType}")
    Connection findByAll(Integer peopleId,Integer bookId,Integer bookType);

    @Delete ("delete from connection where id=#{id}")
    void del(Integer id);

    @Delete ("delete from connection where people_id=#{peopleId} and book_id=#{bookId} and book_type=#{bookType}")
    void delByAll(Integer peopleId,Integer bookId,Integer bookType);

    @Insert("insert into connection values(null,#{peopleId},#{bookId},#{bookType})")
    void addConnection(Connection connection);
}
